]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
main: Add support for -high-contrast theme variants
authorFlorian Müllner <fmuellner@gnome.org>
Sat, 29 Nov 2014 13:37:19 +0000 (13:37 +0000)
committerFlorian Müllner <fmuellner@gnome.org>
Sat, 29 Nov 2014 17:13:03 +0000 (18:13 +0100)
While the default Shell style is fairly decent with regard to
accessibility requirements, having the ability to tweak certain
aspects where the regular style works less well is still useful.
For this purpose, try to load a -high-contrast theme variant of
the default stylesheet when a high-contrast theme is requested
(as determined by the GTK+ theme name).

https://bugzilla.gnome.org/show_bug.cgi?id=740447

js/ui/main.js

index 36d7591695d6e792b1e588dcf840c7bffe2d0c43..0b22a368d6e7f57c2e0ecd8bed86b74b933783ab 100644 (file)
@@ -4,6 +4,7 @@ const Clutter = imports.gi.Clutter;
 const Gdk = imports.gi.Gdk;
 const Gio = imports.gi.Gio;
 const GLib = imports.gi.GLib;
+const Gtk = imports.gi.Gtk;
 const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 const Meta = imports.gi.Meta;
@@ -75,7 +76,8 @@ let _cssStylesheet = null;
 let _a11ySettings = null;
 
 function _sessionUpdated() {
-    _loadDefaultStylesheet();
+    if (sessionMode.isPrimary)
+        _loadDefaultStylesheet();
 
     wm.setCustomKeybindingHandler('panel-main-menu',
                                   Shell.KeyBindingMode.NORMAL |
@@ -109,6 +111,8 @@ function start() {
 
     sessionMode = new SessionMode.SessionMode();
     sessionMode.connect('updated', _sessionUpdated);
+    Gtk.Settings.get_default().connect('notify::gtk-theme-name',
+                                       _loadDefaultStylesheet);
     _initializeUI();
 
     shellDBusService = new ShellDBus.GnomeShell();
@@ -225,24 +229,36 @@ function _initializeUI() {
     });
 }
 
-function _getDefaultStylesheet() {
+function _getStylesheet(name) {
     let stylesheet;
 
-    stylesheet = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/' + sessionMode.stylesheetName);
+    stylesheet = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/' + name);
     if (stylesheet.query_exists(null))
         return stylesheet;
 
-    stylesheet = Gio.File.new_for_path(global.datadir + '/theme/' + sessionMode.stylesheetName);
+    stylesheet = Gio.File.new_for_path(global.datadir + '/theme/' + name);
     if (stylesheet.query_exists(null))
         return stylesheet;
 
     return null;
 }
 
-function _loadDefaultStylesheet() {
-    if (!sessionMode.isPrimary)
-        return;
+function _getDefaultStylesheet() {
+    let stylesheet = null;
+    let name = sessionMode.stylesheetName;
 
+    // Look for a high-contrast variant first when using GTK+'s HighContrast
+    // theme
+    if (Gtk.Settings.get_default().gtk_theme_name == 'HighContrast')
+        stylesheet = _getStylesheet(name.replace('.css', '-high-contrast.css'));
+
+    if (stylesheet == null)
+        stylesheet = _getStylesheet(sessionMode.stylesheetName);
+
+    return stylesheet;
+}
+
+function _loadDefaultStylesheet() {
     let stylesheet = _getDefaultStylesheet();
     if (_defaultCssStylesheet && _defaultCssStylesheet.equal(stylesheet))
         return;